package com.example.demo.controller;

import com.example.demo.service.Demo1Service;
import lombok.RequiredArgsConstructor;
import org.springframework.graphql.data.method.annotation.Argument;
import org.springframework.graphql.data.method.annotation.QueryMapping;
import org.springframework.graphql.data.method.annotation.SchemaMapping;
import org.springframework.stereotype.Controller;

import java.util.HashMap;
import java.util.Map;

@Controller
@SchemaMapping(typeName = "Demo1Query")
@RequiredArgsConstructor
public class Demo1QueryController {

  @QueryMapping
  public Map<String, Object> demo1(@Argument("key") String key) {
    return new HashMap() {
      {
        put("key", key);
        put("name", "sdsdfsd");
      }
    };
  }

  @SchemaMapping
  public String hello() {
    return String.format("hello");
  }

  @SchemaMapping
  public String sayHi() {
    return "Hi 2233!";
  }

  @SchemaMapping
  public String sayHello(@Argument("name") String name) {
    return String.format("hello %s", name);
  }
}
